#include "pcfdataitem.h"
#include <QDebug>
PcfDataitem::PcfDataitem(QObject *parent) : QObject(parent)
{
    PcfData::gestance();
}

PcfDataitem::~PcfDataitem()
{

}

int PcfDataitem::readTempture()
{
    int val =  PcfData::gestance()->readPcf(A2);
    //  return val;
    qDebug()<<"PcfDataitem::readTempture val=1="<<val;
    int t=(val*500)/256;
    qDebug()<<"PcfDataitem::readTempture  t=1="<< t;
    int t1=5000-t;
    qDebug()<<"PcfDataitem::readTempture  t1=1="<< t1;
    int vals =(t1*10)/t ;
    qDebug()<<"PcfDataitem::readTempture vals=2="<<vals;
    // return val;
    /* t=Val;
    t=t*19.6;//;
    t1=t/1000; //t1为电压值
    t1=(5000-t)/t1;
    Val=(unsigned int)t1*10; // 计算得电阻值 */
    int da=val;
    int max=97;
    int min=0;

    //    while(1) // 查表求出温度值
    //    {
    //       int mid=(max+min)/2;
    //        if(Table[mid]<da) max=mid;
    //        else min=mid;
    //        if((max-min)<=1) break;
    //    }
    return vals;
}

int PcfDataitem::readAdc()
{
    int val = PcfData::gestance()->readPcf(A3);
    qDebug()<<"PcfDataitem::readAdc val=1="<<val;
    val = val - 130;
    if(val >= 100){
        val = 100;
    }
    if(val<= 0){
        val =0;
    }
    return val;
}
